//
//  ApplyDrivingCell.m
//  Cycling
//
//  Created by 迟国强 on 2023/3/28.
//

#import "ApplyDrivingCell.h"

@implementation ApplyDrivingCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.applyBtn.layer.cornerRadius = 27;
    self.applyBtn.layer.masksToBounds = YES;
    // Initialization code
    self.cellsSwitch = [[CycSwitch alloc] initWithFrame:CGRectMake(0, 0, 60, 30)];
    [self.cellsSwitch setOnTintColor:COLOR_TOPIC_SELECT];
    [self.cellsSwitch setContrastColor:COLOR_OFFLINE];
    [self.cellsSwitch setTintColor:COLOR_OFFLINE];
    [self.cellsSwitch addTarget:self action:@selector(switchClick:) forControlEvents:UIControlEventValueChanged];
    [self.contentView addSubview:self.cellsSwitch];
    [self.cellsSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(60, 30));
        make.right.equalTo(self.contentView).offset(-MARGIN_MAX);
        make.centerY.mas_equalTo(self.mas_centerY);
    }];
    
    [self.applyBtn setTitle:CycLocalizedString(@"Request a test ride", @"申请试驾") forState:UIControlStateNormal];

}
- (void)switchClick:(CycSwitch *)sender {
    if (self.switchBlock) {
        self.switchBlock(sender.on);
    }
}

- (IBAction)applyDriving:(UIButton *)sender {
    self.block(@"1212");
}

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{
    
    if (highlighted) {
        self.contentView.backgroundColor = COLOR_WHITE;
    }else{
        self.contentView.backgroundColor = COLOR_WHITE;
    }
    [super setHighlighted:highlighted animated:animated];
}

@end
